<extend name="Base/common"/>
<block name="right">
    <!-- right end -->
    <div class="main-container">
        <div class="padding-md">
            <div class="row">
                <div class="col-sm-12">
                    <div class="page-title">
                        缴费方式管理
                    </div>
                </div>
            </div>
            <form  method="post" action="__SELF__"class="form-horizontal" id="jsForm">
                <input type="hidden" name="id" value="{$user.id}">
                <div class="panel-body">
                    <div class="form-group" style="color:red;">
                        {$user['id']?'修改':'添加'}缴费信息
                    </div>
                    <div class="form-group" style="height: 30px;">
                        <label class="col-md-1 control-label" style=" margin-top: -10px;">缴费方式</label>
                        <span class="error" for="client"></span>
                        <div class="col-md-3">
                            <div class="input-group">
                                <input type="radio" name="fkfs" value="1" onclick="yingcang('icoA_div')" checked>网上支付&nbsp;&nbsp;&nbsp;
                                <input type="radio" name="fkfs" value="3" onclick="yingcang('icoA_div')" {$user['fkfs']==3?'checked':''}>现金支付&nbsp;&nbsp;&nbsp;
                                <input type="radio" name="fkfs" value="2" onclick="xianshi('icoA_div')" {$user['fkfs']==2?'checked':''}>汇款凭证上传
                                <div style="display: none;margin-top: 10px;" id="icoA_div">
                                    <input type='text' name='textfield '  disabled style="display: none" />
                                    <input type="hidden" name="upload_ids" id="upload_icoA" value="{$user.upload_ids}" />
                                    <input type="file"  onchange="ajaxFileUpload('icoA',1);" id="icoA" name="icoA" style="width: 67px;">
                                    <span style="color:red;font-size: 12px;">(目前只支持后缀名为 jpg , png , jpeg , bmp 格式)</span>
                                    <div id="show_upload_message_icoA" class="span1">
                                        <foreach name="upload_ids_arr" item="vo" >
                                            <if condition="$vo neq ''">
                                                <div id="file_id_{$vo}">
                                                    <a style="color:blue;" target="_blank" href="{:U('down_file')}?file_id={$vo}">查看图片</a>
                                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                                    <a style="color:blue;" href="javascript:del_file({$vo},'icoA')">删除</a>
                                                </div>
                                            </if>
                                        </foreach>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                    <p style="clear: both"></p>
                    <div class="form-group" style="height: 30px;">
                        <label class="col-md-1 control-label" style=" margin-top: -10px;">是否需要发票</label>
                        <span class="error" for="client"></span>
                        <div class="col-md-3">
                            <div class="input-group">
                                <input type="radio" name="dwsh" value="1" onclick="yingcang('kpdw')" checked>无需发票&nbsp;&nbsp;&nbsp;
                                <input type="radio" name="dwsh" value="2" onclick="xianshi('kpdw')" {$user['dwsh']==2?'checked':''}>需要发票&nbsp;&nbsp;&nbsp;
                                <input type="text" placeholder="请填写发票抬头" name="kpdw" id="kpdw" value="{$user.kpdw}" style="padding: 5px;width: 270px;display: none"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group" style="height: 30px;">
                        <label class="col-md-1 control-label" style=" margin-top: -10px;">报告领取</label>
                        <span class="error" for="client"></span>
                        <div class="col-md-3">
                            <div class="input-group">
                                <input type="radio" name="qbfs" value="1" onclick="yingcang('kddz')" checked>自取&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="radio" name="qbfs" value="2" onclick="xianshi('kddz')" {$user['qbfs']==2?'checked':''}>快递&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="text" placeholder="请填写收件地址" name="kddz" value="{$user.kddz}" id="kddz" style="padding: 5px;width: 270px;display: none"/>
                            </div>
                        </div>
                    </div>


                </div>
                <div class="bs-example" data-example-id="form-validation-states-with-icons">
                    <div class="panel-footer">
                        <div class="row">
                            <div class="col-sm-8">
                                <button type="submit" class="action-button" onclick="return form_sub()">保&nbsp&nbsp存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <table class="table table-striped no-margin">
            <thead>
            <tr>
                <th>缴费方式</th>
                <th>是否需要发票</th>
                <th>报告领取</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody class="cy_takeyouflytb">
            <empty name="_list">
                <tr>
                    <td colspan="8">对不起暂时没有数据！</td>
                </tr>
                <else/>
                <volist name="_list" id="vo" >
                    <tr>
                        <td>
                            <if condition="$vo['fkfs'] eq 1">
                                网上支付
                                <elseif condition="$vo['fkfs'] eq 3" />
                                现金支付
                                <else />
                                汇款凭证上传
                            </if>
                        </td>
                        <td>{$vo['dwsh']==1?'无需发票':"需要发票-($vo[kpdw])"}</td>
                        <td>{$vo['qbfs']==1?'自取':"快递-($vo[kddz])"}</td>
                        <td>
                            <a href="{:U('User/payment')}?id={$vo[id]}" style="color:blue;">编辑</a>
                            |
                            <a href="{:U('User/del_user',array('id'=>$vo['id']))}" onclick="return confirm('是否确认删除？')" style="color:blue;">删除</a>
                        </td>
                    </tr>
                </volist>
            </empty>
            </tbody>
        </table>
    </div><!-- /main-container -->
</block>
<block name="script">
    <script type="text/javascript" src="__PUBLIC__/js/ajaxfileupload.js"></script>

    <script>
        $(function(){

            highlight_nav2('{:U('User/payment')}');


            if($("input[name='fkfs']:checked").val()==2){
                $('#icoA_div').show();
            }
            if($("input[name='qbfs']:checked").val()==2){
                $('#kddz').show();
            }
            if($("input[name='dwsh']:checked").val()==2){
                $('#kpdw').show();
            }
            //jquery.validate
            $("#jsForm").validate({
            })
        })
        //配置错误提示的节点，默认为label，这里配置成 span （errorElement:'span'）
        $.validator.setDefaults({
            errorElement:'span'
        });

        //          //配置通用的默认提示语
        //          $.extend($.validator.messages, {
        //            required: '必填',
        //              equalTo: "两次输入密码不一致"
        //          });
        //          jQuery.validator.addMethod("mail", function (value, element) {
        //            var mail = /^[a-z0-9._%-]+@([a-z0-9-]+\.)+[a-z]{2,4}$/;
        //            return this.optional(element) || (mail.test(value));
        //          }, "邮箱格式不对");

          //显示
            function xianshi(type){
                $("#"+type).show();
            }
            //隐藏
            function yingcang(type){
                $("#"+type).hide();
        }
        function form_sub(){
            var file = $("input[name='fkfs']:checked").val();
            if(parseInt(file) == 2) {
                if($('#upload_icoA').val() == ''){
                    alert('请选择汇款凭证上传');
                    return false;
                }
            }

            var dwsh = $("input[name='dwsh']:checked").val();
            if(parseInt(dwsh) == 2) {
                if($('#kpdw').val() == ''){
                    alert('请填写发票抬头');
                    return false;
                }
            }

            var qbfs = $("input[name='qbfs']:checked").val();
            if(parseInt(qbfs) == 2) {
                if($('#kddz').val() == ''){
                    alert('请填写收件地址');
                    return false;
                }
            }

        }

    </script>
</block>